﻿//  -------------------- iSharePoint -------------------- //
// 
//  Company:	IT Complex, LLC
//  Project:	Smart.Documents
//  File name:	LookupFieldWithPickerHelper.cs
//  Developer:	Solomatov Igor
//  Created:	16.04.2012
// 
//  -------------------- iSharePoint -------------------- //

using System.Web;
using Microsoft.SharePoint;

// ReSharper disable CheckNamespace

namespace Smart.Documents.Fields.LookupFieldWithPicker
// ReSharper restore CheckNamespace
{
	public class LookupFieldWithPickerHelper
	{
		public static bool IsSearchableField(SPField field)
		{
			return (field.Id == SPBuiltInFieldId.FileLeafRef || field.Hidden == false &&
			        (field.Type == SPFieldType.Counter
			         || field.Type == SPFieldType.Boolean
			         || field.Type == SPFieldType.Integer
			         || field.Type == SPFieldType.Currency
			         || field.Type == SPFieldType.DateTime
			         || field.Type == SPFieldType.Number
			         || field.Type == SPFieldType.Text
			         || field.Type == SPFieldType.URL
			         || field.Type == SPFieldType.User
			         || field.Type == SPFieldType.Choice
			         || field.Type == SPFieldType.MultiChoice
			         || field.Type == SPFieldType.Lookup
			         || (field.Type == SPFieldType.Calculated && ((SPFieldCalculated) field).OutputType == SPFieldType.Text))
			       );
		}

		public static string GetResourceString(string key)
		{
			const string resourceClass = "iLoveSharePoint.Fields.LookupFieldWithPicker";

			var value = HttpContext.GetGlobalResourceObject(resourceClass, key).ToString();

			return value;
		}
	}
}